$(function(){
	var token=localStorage.getItem("token");
	gridObj = $.fn.bsgrid.init('g_tabYeh', {
		ajaxType : 'get',
		url :  server_url+'/rest/supplyCommission/commissionList.do?ran=' + Math.random() + '&token=' + token,
		autoLoad : true,
		pageSizeSelect : true,
		stripeRows : true,
		pageSize : 10,
		displayBlankRows : false,
		isProcessLockScreen : true,
		rowSelectedColor : false,
		showPageToolbar:true,
		rowHoverColor:true
	});	
	
});
function operate(record, rowIndex, colIndex, options) {
    return '<a href="javascript:editCommission(\'' + gridObj.getRecordIndexValue(record, 'supplyID') + '\');">修改点位</a>';
}
function orderCommission(record, rowIndex, colIndex, options){
	return ["单笔订单金额",record.orderPercentage+'‰','超过',record.overNumber,'元，按照',record.limitNumber,'元封顶计算'].join('');
}
// 数据表格参数查询
function doSearch() {
	searchParames = $('#myform').serialize();
    gridObj.search(searchParames);		
	//console.log(searchParames);
}

// 编辑
function editCommission(id) {
	var url='supplyCommission/editCommission.do?id='+id;
	tl_config.loadToWorkArea(url);
}
function deleteCommission(){

	var idArr=getCheckedIds();
	var ids=idArr.toString();
	console.log(ids);
	if(empty(ids)){
		easyDialog.open({
			  container : {
				  header : '温馨提示',
			    content : '请选择要操作的记录！'
			  },
			  autoClose : 2000
			});
		return;
	}
	easyDialog.open({
		  container : {
			  header : '删除确认',
			  content : '您确定要删除这些点位么？',
			  yesFn : function(){
		    	$.ajax({
					url:server_url+'/rest/supplyCommission/deleteCommission.do?ran='+Math.random()+"&token="+token,
					type:'get',
					data:{ids:ids},
					success:function(data){
						if(data.retCode=="0000"){
							doSearch();
						}
						else{
							easyDialog.open({
								  container : {
									  header : '提示',
								    content : data.retMsg
								  },
								  autoClose : 2000
								});
							
						} 
						
					}
				})
		    },
		    noFn : true
		  }
		});
}
function getCheckedIds() {
	// values are array
	return gridObj.getCheckedValues('id');
}